Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

token-types

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

token-types

Common token types for decoding and encoding binairy values

  • 0.9.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4.9M
decreased by-6.43%
Maintainers
1
Weekly downloads
 
Created

What is token-types?

The token-types npm package provides a collection of token parsers for binary data types, facilitating the reading and interpretation of various data types from binary streams. This is particularly useful in applications dealing with multimedia files, where metadata and content need to be extracted or interpreted from binary formats.

What are token-types's main functionalities?

Reading integer values

This feature allows the reading of unsigned 32-bit integers from a buffer in little-endian format. It is useful for parsing low-level binary data structures.

const Token = require('token-types');

const uint32Token = Token.UINT32_LE;
const buffer = Buffer.from([0x01, 0x00, 0x00, 0x00]);
const value = uint32Token.get(buffer, 0);
console.log(value); // Outputs: 1

Reading string values

This feature enables the extraction of ASCII strings from binary data. It supports specifying the length of the string and the encoding, making it versatile for reading text data embedded in binary streams.

const Token = require('token-types');

const stringToken = new Token.StringType(5, 'ascii');
const buffer = Buffer.from('hello');
const value = stringToken.get(buffer, 0);
console.log(value); // Outputs: 'hello'

Other packages similar to token-types

FAQs

Package last updated on 08 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc